package br.com.mensageiro.apresentacao.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import br.com.mensageiro.negocio.dao.GenericDAO;
import br.com.mensageiro.negocio.entidade.Usuario;

@FacesConverter(value = "usuarioConverter", forClass = Usuario.class)
public class UsuarioConverter extends GenericDAO<Usuario> implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {		
		return value;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent componet, Object value) {
		Usuario usuario = (Usuario) value;
		return String.valueOf(usuario.getId());
	}

	public UsuarioConverter() {
		super(Usuario.class);
	}
}
